<?php
namespace app\behavior;
class Behaviors
{
    public function run(&$response)
    {
        $content = $response->getContent();
        $content = $this->removeEmptyLines($content);
        $response->content($content);
    }
    protected function removeEmptyLines($text) {
        // 将文本按行分割成数组
        $lines = explode("\n", $text);
        
        // 过滤掉空行或只包含空白字符的行
        $lines = array_filter($lines, function($line) {
            return trim($line) !== '';
        });
        
        // 重新组合文本
        return implode("\n", $lines);
    }
}